DELPHI IDE Pathes - Felix John COLIBRI. |
- abstract : How to include a Unit for compilation, loading in the Editor or debugging: the Windows environment PATH, the RSVARS.BAT $(BDS), the Registry pathes, the "Tools | Environment | Library" and "Project | Option"
pathes. Package pathes.
- key words : Windows Environment Variables, PATH, Rsvars.bat, registry, Tools Environment Variables, Tools Options Library, Browsing Path, Project Options, Search Path, Package
- software used : Windows XP Home, Delphi 6, Delphi XE7
- hardware used : Pentium 2.800Mhz, 512 M memory, 140 G hard disc
- scope : Delphi 1 to 8, Delphi 2005, to Delphi 2010, Delphi XE to Delphi
XE8, Seatle, Berlin, Tokyo
- level : Delphi developer
- plan :
1 - The many Delphi IDE pathes
This paper explains what pathes are used by the Delphi IDE Delphi uses several pathes: - the Windows environment variables
- the Registry pathes
- the RSVARS.BAT definitions
- the Tools | Options pathes
- the Project | Options pathes
- the .dpr pathes
2 - The Windows Environment Variable PATH When we install Delphi, the PATH environment variable is modified.
We use a simple utility to display the environment variables: We split the Path variable in the individual pathes:
and - we hilighted the Xe7 pathes
- there are also Xe8 pathes, Xe3 pathes and Delphi 6 pathes
- there are Android pathes we used for direct android compilations
3 - The Rsvars.Bat variables The Delphi IDE uses pathes shortcuts, like $(BDS). Those definitions are stored
in rsvars.bat file stored in Delphi's Bin\ folder C:\Program Files\Embarcadero\RAD Studio\10.0\bin\
Here is the content of our Delphi Xe7 rsvars.bat file:
@SET BDS=C:\Program Files\Embarcadero\Studio\15.0 @SET BDSINCLUDE=C:\Program Files\Embarcadero\Studio\15.0\include @SET BDSCOMMONDIR=C:\Documents and Settings\All Users\Documents\Embarcadero\Studio\15.0
@SET FrameworkDir=c:\WINDOWS\Microsoft.NET\Framework\v3.5 @SET FrameworkVersion=v3.5 @SET FrameworkSDKDir= @SET PATH=%FrameworkDir%;%FrameworkSDKDir%;C:\Program Files\Embarcadero\Studio\15.0\bin;C:\Program
Files\Embarcadero\Studio\15.0\bin64;C:\Documents and Settings\All Users\Documents\Embarcadero\InterBase\redist\InterBaseXE3\IDE_spoof;%PATH% @SET LANGDIR=EN @SET PLATFORM= @SET PlatformSDK= @SET CG_BOOST_ROOT=C:\Program
Files\Embarcadero\Studio\15.0\include\boost_1_39 @SET CG_64_BOOST_ROOT=C:\Program Files\Embarcadero\Studio\15.0\include\boost_1_50 | and if we display each path of PATH in its own directory, we have
%FrameworkDir% %FrameworkSDKDir% C:\Program Files\Embarcadero\Studio\15.0\bin
C:\Program Files\Embarcadero\Studio\15.0\bin64 C:\Documents and Settings\All Users\Documents\Embarcadero\InterBase\redist\InterBaseXE3\IDE_spoof %PATH% | and replacing each parameter by its value
c:\WINDOWS\Microsoft.NET\Framework\v3.5 C:\Program Files\Embarcadero\Studio\15.0\bin
C:\Program Files\Embarcadero\Studio\15.0\bin64 C:\Documents and Settings\All Users\Documents\Embarcadero\InterBase\redist\InterBaseXE3\IDE_spoof %PATH% | Note that
- in our Delphi Xe7 version we have no %rameworkSDKDir% (we had not the Mobile Studio installed)
- the last %PATH% is a placeholder for the Windows PATH value (the "SET PATH" being the cmd.exe command which dynamically modifies the value of the
Windows PATH environment variable, concatenating at the end the current in-memory PATH value)
4 - The Windows Registry
The Windows Registry contains the default values that are imported in the IDE. Here is a partial view of the Delphi Xe7 registry:
For our DCC build tools, we created a unit which analyzes our Delphi registry pathes (we only analyzed Delphi 5, Delphi 6, Delphi Xe2, Delphi Xe7 and Berlin). Here is the display of the Xe7 registry :
Please note: - some variables are not defined in rsvars.bat: BDSLIB and BDSUSERDIR. Those are defined by the IDE itself
- BDSLIB is BDS plus "\Lib"
- BDSUSERDIR is your user dir plus "Embarcadero\Studio\15.0"
5 - Tools | Options | Library The menu item Tools contains additional information which are used for all projects
5.1 - Tools | Environment Variables Here is a display of our variables : and - the top part is computed by the IDE using the Window registry and IDE's own computations. For instance,
- BDSLIB is defined as c:\program files\embarcadero\studio\15.0\lib
- BDSUSERDIR is defined as C:\Documents and Settings\Felix\Mes documents\Embarcadero\Studio\15.0
- we cannot delete any of those variables
- we can override some of those values by selecting an item and clicking "add override"
- the bottom part are "user overrides". Here are the overrides of the system variables or new variables. Some of those "user" variables are already
defined by the IDE
5.2 - Tools | Options | Delphi Options | Library> Here are our Library pathes :
5.2.1 - Selecting the Platform Delphi contains pathes for each platform. At the top of this dialog, we first select the target for which we want to
display the pathes. In our case the ""32-bit Windows" platform is selected
5.2.2 - Library Path :
We can display and modify the library pathes by clicking on the ellipsis "..." icon at the rigth of the "Library Path" combo:
For the selected Win 32 platform, the detailed content of our list is: $(BDSLIB)\$(Platform)\release
$(BDSUSERDIR)\Imports $(BDS)\Imports $(BDSCOMMONDIR)\Dcp $(BDS)\include C:\Program Files\FastReports\LibD21 C:\Program Files\Raize\CS5\Lib\RS-XE7\Win32 C:\Program Files\madCollection\madBasic\BDS15\win32
C:\Program Files\madCollection\madKernel\BDS15\win32 C:\Program Files\madCollection\madSecurity\BDS15\win32 C:\Program Files\madCollection\madShell\BDS15\win32 C:\prog\libs\jedi\jcl_2018\jcl-master\jcl\lib\d21\win32
C:\prog\libs\jedi\jcl_2018\jcl-master\jcl\source\include C:\prog\libs\jedi\jvcl_2018\jvcl-master\jvcl\lib\D21\win32 C:\prog\libs\jedi\jvcl_2018\jvcl-master\jvcl\common C:\prog\libs\jedi\jvcl_2018\jvcl-master\jvcl\Resources
| And - the items come from the Windows Registry
- the first row is always $(BDSLIB)\$(Platform)\release
- As explained $(BDSLIB) is BDS+ "\Lib".
- $(Platform) will be the platform selected in the project manager for some project. For instance, we selected Win 32
In our case
so $(BDSLIB)\$(Platform)\release will be resolved as c:\Program Files\Embarcadero\Studio\15.0\LIB\Win32\release
- $(BDSUSERDIR)\Imports will resolve to
C:\Documents and Settings\Felix\Mes documents\Embarcadero\Studio\15.0\Imports will depend on the current user. In our case - $(BDSCOMMONDIR)\Dcp will resolve to
C:\Documents and Settings\All Users\Documents\Embarcadero\Studio\15.0\Dcp
The purpose of those pathes is to allow the compiler to include .DCUs without having to recompile the .PAS.
So if you installed DevExpress Vcl (223 packages !) or Jedi Jvcl (271 packages, 264 .DCUs) it certainly will speed up your compilation if you let the compiler include the .DCU instead of compiling the .PAS
IMPORTANT, note that
- since the first two entries ($(BDSLIB)\$(Platform)\release and $(BDSUSERDIR)\Imports) cannot be resolved for all platforms and users, those two items are ALWAYS grayed.
The items will be resolved at compile time. And they are very important.
Therefore NEVER click "Delete Invalid Pathes" Should this happen, add those items back using the values presented here
5.2.3 - The Browsing Path Our Browsing Path contains :
$(BDS)\OCX\Servers $(BDS)\SOURCE\VCL $(BDS)\source\rtl\common $(BDS)\SOURCE\RTL\SYS $(BDS)\source\rtl\win
$(BDS)\source\ToolsAPI $(BDS)\SOURCE\IBX $(BDS)\source\Internet $(BDS)\SOURCE\PROPERTY EDITORS $(BDS)\source\soap $(BDS)\SOURCE\XML $(BDS)\source\Indy10\Core $(BDS)\source\Indy10\System $(BDS)\source\Indy10\Protocols
$(BDS)\source\fmx $(BDS)\source\databinding\components $(BDS)\source\databinding\engine $(BDS)\source\databinding\graph $(BDS)\source\data $(BDS)\source\data\ado $(BDS)\source\data\bde $(BDS)\source\data\cloud
$(BDS)\source\data\datasnap $(BDS)\source\data\dbx $(BDS)\source\data\dsnap $(BDS)\source\data\Test $(BDS)\source\data\vclctrls $(BDS)\source\data\datasnap\connectors $(BDS)\source\data\datasnap\proxygen
$(BDS)\source\DataExplorer $(BDS)\source\DUnit\Contrib\DUnitWizard\Source\Common $(BDS)\source\DUnit\Contrib\DUnitWizard\Source\Common\dunit $(BDS)\source\DUnit\Contrib\DUnitWizard\Source\DelphiExperts\Common
$(BDS)\source\DUnit\Contrib\DUnitWizard\Source\DelphiExperts\DUnitProject $(BDS)\source\DUnit\Contrib\DUnitWizard\Source\DelphiExperts\DUnitProject\dunit $(BDS)\source\DUnit\src $(BDS)\source\DUnit\tests $(BDS)\source\Experts
$(BDS)\source\indy\abstraction $(BDS)\source\indy\implementation $(BDS)\source\indyimpl $(BDS)\source\LiveTile $(BDS)\source\Property Editors\Indy10 $(BDS)\source\soap\wsdlimporter $(BDS)\source\Visualizers
$(BDS)\source\xtab $(BDS)\source\DUnit\Contrib\XMLReporting $(BDS)\source\DUnit\Contrib\XPGen $(BDS)\source\data\rest $(BDS)\source\data\firedac $(BDS)\source\tethering C:\Program Files\FastReports\LibD21
C:\Program Files\madCollection\madBasic\Sources C:\Program Files\madCollection\madKernel\Sources C:\Program Files\madCollection\madSecurity\Sources C:\Program Files\madCollection\madShell\Sources
C:\prog\libs\jedi\jcl_2018\jcl-master\jcl\source\common C:\prog\libs\jedi\jcl_2018\jcl-master\jcl\source\windows C:\prog\libs\jedi\jcl_2018\jcl-master\jcl\source\vcl C:\prog\libs\jedi\jvcl_2018\jvcl-master\jvcl\common
C:\prog\libs\jedi\jvcl_2018\jvcl-master\jvcl\run | So basically it contains the pathes of - the Delphi source\
- some components sources (FDastReport, Madshi, Jedi)
and we can remove or add other pathes
Those pathes are mainly used by the Delphi editor, to be able to load the text of some unit by simply using Ctrl Click on the unit name or some identifier
5.2.4 - Debug DCU Path Our content is $(BDSLIB)\$(Platform)\debug
C:\prog\libs\jedi\jcl_2018\jcl-master\jcl\lib\d21\win32\debug |
6 - Project | Options 6.1 - How to include a unit
There are several ways to include a Unit in a Delphi project - saving it in the .DPR (.DPK) path
- adding it to the project .DPR
- specifying the Search Path in the "Project | Options"
- specifying the Library Path / Browsing Path
A simple example Let's start a first VCL project | "File | New | Vcl Forms Application"
| | save the DPR as p_project_1.dpr, u_main.pas in some pathes_demo\project_1\ path |
| add some unit "File | New | Delphi Unit" and save it as u_calc.pas in a units\ sub directory | |
compile everything | | the .EXE and the .DCU are save in a win32\debug\ subdirectory of the .DPR path:
| |
since we want to reuse the specify the .Exe and .DCU pathes: "Project | Options | Delphi Compiler | Output Directory"
The default is .$(Platform)$(Config) In our case for the Win32 platform in debug mode, it would be a the Win32\debug\ subdirectory of the .DPR folder Recompile Change the following values
- replace the "Output Directory" in "..\_exe"
- replace the "Unit Output Directory" in "_exe\_dcu"
| |
the .DCUs are now all in the _exe\dcu\ folder |
Now let's create another project, project_2, which will use the u_calc unit:
6.1.1 - Copying u_calc in the .DPR project This is a simple solution but would lead to massive code duplication
6.1.2 - Including the u_calc in the .DPR To include the unit in the .DPR
| "Project | Add to Project" then navigate to the project_1\units\ folder and select u_calc.pas | |
compile |
The .DPR source ("Project | View Source") will now contain a line including the u_calc file, and the project manager also contains a node for this unit :
Please note that - the path has nicely been compile as a relative path
- we could also manually add lines to add other units (possibly using some
utility to automate this process), and then could use absolute path.
- if we move or rename the units or the pathes, we must make sure that those .DPR additions are still valid.
This is very nice but could be tedious should we want to include massive libraries (Jedi, DevExpress etc). Therefore it is easier to somehow tell the IDE where it can find the relevant
units without having to implicitely include them in the .DPR. Hence the "Project Option | Search Pathes" or "Tools | Options | Library"
6.1.3 - The Project | Options | Search Pathes
The next more local parameter is in the "Project Options;
In this case, the include path will be saves in the .DPROJ:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> ... <PropertyGroup Condition="'$(Cfg_1_Win32)'!=''"> <DCC_UnitSearchPath>
C:\programs\us\ide\pathes_demo\project_1\units;$(DCC_UnitSearchPath) </DCC_UnitSearchPath>
<DCC_DcuOutput>..\_exe\dcu</DCC_DcuOutput> <DCC_ExeOutput>..\_exe</DCC_ExeOutput> <VerInfo_Locale>1033</VerInfo_Locale>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo> <DCC_RemoteDebug>false</DCC_RemoteDebug> </PropertyGroup> |
Note that - using the "ellipsis" to include the path will add an absolute path. You can modify this path into a relative path, but you have to compute it manually
- make sure there is no conflict between the units included in the "Search Pathes" and those directly included in the .DPR (in case of several units with the same name in different pathes or in case of change of unit name / path names)
- we added a Search Path only for Win 32 in debug mode. This is specified in the top level combobox of the "Project Option | Delphi Compiler" dialog
We could place the include at some other target / debug level by selecting another level :
In general, we start including at the highest level ("all configurations") and then override or add when required for the more specific level ("32 bit
Windows Platform" for instance)
The drawbacks of the Search path are - the units are not displayed in the Project Manager treeview. You still can open a unit by "Ctrl Click" on the unit in some Uses list, or by "Ctrl
Click" on some of the Unit's identifiers
- the search pathes apply to this project only.
6.1.4 - Project | Options | Search Pathes for dcu To avoid the recompilation of u_calc.pas, we can simply add the u_calc.DCU path
in the Search Pathes
The u_calc.pas unit cannot be loaded in the Editor with "Ctrl Click":
6.1.5 - The Tools | Options | Library
We can also specify to include some units using the "Tools | Options | Library"
The u_calc.pas unit cannot be loaded in the Editor with "Ctrl Click":
So adding the dcu's path to "Tools | Options | Library Path" is the same as adding the dcu's path to "Project | Options | Delphi Compiler | Search Pathes", but the "Tools ..." will work for any project
6.1.6 - Tools | Options | Browsing Path To be able to load the unit in the Editor and debug the u_calc unit, we must - either add the unit's path to "Project | Options | Delphi Compiler | Search Pathes"
- add the unit's path to "Tools | Options | BROWSING PATH"
Therefore
Please note
- adding the .pas path to the "Tools | Options | Browsing Path" does not allow the compiler to find the u_calc.pas (F1026 File not found) (whereas the "Project | Options | Delphi Compiler | Search Pathes" did allow both
compilation, loading with "Ctrl Click" and debugging). To compile, the "Tools | Options | Library Path" must specify where the u_calc.dcu is located
7 - Custom path parameters If you have to include several related pathes, you can create your own parameters - either in the Windows Environment Variables
- or in "Tools | Options | Environment Variables"
Here is an example of the second option:
We can now use this variable as $(calc) in any path we specify in the IDE.
Another solution would be to use the SUBST windows command
8 - Delphi Pathes Summary Delphi Pathes Summary 8.1 - Finding units
- the Compile can compile a Unit if
- the .PAS is in the .DPR folder
- the .PAS is include in the .DPR file
- the .PAS is in a path included in "Project | Options | Delphi Compiler | Search Pathes"
- the .DCU is in a path included in "Project | Options | Delphi Compiler | Search Pathes"
- the .DCU is in a pas included in "Tools | Options | Library Path"
- the Editor can load a .PAS by using "Ctrl Click" on the unit name listed in a Uses clause or an identifier of the Interface of this Unit, and the debugger will load the unit if
- the .PAS is in the .DPR folder
- the .PAS is include in the .DPR file
- the .PAS is in a path included in "Project | Options | Delphi Compiler | Search Pathes"
- the .PAS is in a path included in "Tools | Options | Browsing Path"
If you have several units with the same name (a big NO in our own projects) Delphi, in a typical PASCAL way, will always look for the nearest solution.
8.2 - Where to place the DCU's
The default Delphi 6 solution was to keep the DCUs with the .PAS. For the post Xe versions, we potentially have 7 platfoms, and 2 variants (debug and release). Using the "Project | Options", we could specify 14 dcu pathes !
We always used a separate path to group all DCUs of project families. We often migrate projects for Win 32 and Win 64. Keeping a single DCU path forces the recompilation of all DCUs, including the packages. Therefore we routinely use 2
locations for those projects. However we do not separate debug and release (when the code does not contain different compiling options or $IFDEFs for debug and release).
8.3 - Compiling Packages
When you install packages, if you do not specify where the DCUs should be saved, you will have to look for the DCU's whenever an application uses the components. To avoid this, the best solution is
- to add the package's .DCU path(es) in "Tools | Options | Library | Library Path"
- if you want to be able to load and debug the package's .PAS, add the .PAS path(es) in "Tools | Options | Library | Browsing Path"
8.4 - Default Project Path Let's us mention another path we often use: when we want to start several projects in some folder, we specify where the "Save Project As" should start.
This can be achieved by specifying the "Toools | Options | Environment Options | Default Project"
8.5 - Nevertheless
We recently had some problems with Berlin where we had many compiler errors - F1026 File not found
- F2039 Could not create output file
We checked the presence of the VCL.xxx qualifiers before Vcl units, checked the
presence of duplicate units, check the PATH length etc. The best solution could be to reinstall Berlin, but we were not allowed do it. Switching from "Compile" to "Build" and direct invocation of DCC somehow solved the problem, albeit in
an unsatisfactory way.
9 - Download the Sources Here are the source code files: The .ZIP file(s) contain: - the main program (.DPR, .DOF, .RES), the main form (.PAS, .DFM), and any other auxiliary form
- any .TXT for parameters, samples, test data
- all units (.PAS) for units
Those .ZIP - are self-contained: you will not need any other product (unless expressly mentioned).
- for Delphi 6 projects, can be used from any folder (the pathes are RELATIVE)
- will not modify your PC in any way beyond the path where you placed the .ZIP (no registry changes, no path creation etc).
To use the .ZIP:
- create or select any folder of your choice
- unzip the downloaded file
- using Delphi, compile and execute
To remove the .ZIP simply delete the folder.
The Pascal code uses the Alsacian notation, which prefixes identifier by program area: K_onstant, T_ype, G_lobal, L_ocal, P_arametre, F_unction, C_lass etc. This notation is presented in the Alsacian Notation paper.
As usual:
- please tell us at fcolibri@felix-colibri.com if you found some errors, mistakes, bugs, broken links or had some problem downloading the file. Resulting corrections will
be helpful for other readers
- we welcome any comment, criticism, enhancement, other sources or reference suggestion. Just send an e-mail to fcolibri@felix-colibri.com.
- or more simply, enter your (anonymous or with your e-mail if you want an answer) comments below and clic the "send" button
- and if you liked this article, talk about this site to your fellow developpers, add a link to your links page ou mention our articles in your blog or newsgroup posts when relevant. That's the way we operate:
the more traffic and Google references we get, the more articles we will write.
Some References
10 - The author Felix John COLIBRI works at the Pascal
Institute. Starting with Pascal in 1979, he then became involved with Object Oriented Programming, Delphi, Sql, Tcp/Ip, Html, UML. Currently, he is mainly
active in the area of custom software development (new projects, maintenance, audits, BDE migration, Delphi
Xe_n migrations, refactoring), Delphi Consulting and Delph
training. His web site features tutorials, technical papers about programming with full downloadable source code, and the description and calendar of forthcoming Delphi, FireBird, Tcp/IP, Web Services, OOP / UML, Design Patterns, Unit Testing training sessions. |